package com.aabte.design2.behavioral.chain.v2;

import com.aabte.design2.behavioral.chain.Request;

import java.util.LinkedList;
import java.util.List;

/**
 * @author Daniel
 * @version 1.0
 * @date 2020/5/3
 */
public class Application {

    public static void main(String[] args) {

        Filter usernameFilter = new UsernameFilter();
        Filter tokenFilter = new TokenFilter();
        Filter endFilter = new EndFilter();

        List<Filter> filters = new LinkedList<>();
        filters.add(usernameFilter);
        filters.add(tokenFilter);
        filters.add(tokenFilter);
        filters.add(endFilter);

        Chain filterChain = new FilterChain(filters);
        filterChain.doFilter(Request.builder().username("tom").token("token").build());

        filterChain = new FilterChain(filters);
        filterChain.doFilter(Request.builder().username("tom").token(null).build());
    }

}
